  package org.flhy.step.idcard.id15to18;

  import java.io.PrintStream;

  public class IdentificationCodeUtil {
/*  6 */   static final int[] wi = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 };
/*  7 */   static int[] vi = { 1, 0, 88, 9, 8, 7, 6, 5, 4, 3, 2 };
/*  8 */   private static int[] ai = new int[18];

    public static boolean Verify(String idcard)
    {
/* 12 */     if (idcard.length() == 15) {
/* 13 */       idcard = uptoeighteen(idcard);
      }
/* 15 */     if (idcard.length() != 18) {
/* 16 */       return false;
      }
/* 18 */     String verify = idcard.substring(17, 18);
/* 19 */     if (verify.equals(getVerify(idcard))) {
/* 20 */       return true;
      }
/* 22 */     return false;
    }

    public static String getVerify(String eightcardid) {
/* 26 */     int remaining = 0;
/* 27 */     if (eightcardid.length() == 18) {
/* 28 */       eightcardid = eightcardid.substring(0, 17);
      }
/* 30 */     if (eightcardid.length() == 17) {
/* 31 */       int sum = 0;
/* 32 */       for (int i = 0; i < 17; i++) {
/* 33 */         String k = eightcardid.substring(i, i + 1);
/* 34 */         ai[i] = Integer.parseInt(k);
        }
/* 36 */       for (int i = 0; i < 17; i++) {
/* 37 */         sum += wi[i] * ai[i];
        }
/* 39 */       remaining = sum % 11;
      }
/* 41 */     return remaining == 2 ? "X" : String.valueOf(vi[remaining]);
    }

    public static String uptoeighteen(String fifteencardid)
    {
/* 46 */     if (org.pentaho.di.core.util.StringUtil.isEmpty(fifteencardid)) {
/* 47 */       return fifteencardid;
      }
/* 49 */     if (fifteencardid.length() != 15) {
/* 50 */       return fifteencardid;
      }
/* 52 */     String eightcardid = fifteencardid.substring(0, 6);
/* 53 */     eightcardid = eightcardid + "19";
/* 54 */     eightcardid = eightcardid + fifteencardid.substring(6, 15);
/* 55 */     eightcardid = eightcardid + getVerify(eightcardid);
/* 56 */     return eightcardid;
    }

    public static void main(String[] args) {
///* 60 */     System.out.println(Verify("360829860812171"));
///* 61 */     System.out.println(uptoeighteen("360829860812171"));
    }
  }


/* Location:              C:\Users\Lenovo\Desktop\kettle-newsee-plugin-0.0.1-SNAPSHOT.zip!\org\flhy\step\idcard\id15to18\IdentificationCodeUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */